var http = require("../../utils/http.js")

Page({
  onSubmit(e){
    console.log(e.detail.value)
    http.post(
      'api/User/Login'+'?account='+e.detail.value.username+'&password='+e.detail.value.password,
      null
      ,
      (data)=>{
        if(data.code==200){

          wx.setStorage({
            data: JSON.stringify({id:data.data.id,role:data.data.role,token:'Bearer '+data.data.token}),
            key: 'Security',
          })

          wx.switchTab({
            url: '/pages/index/index',
          })
        }else{
          wx.showToast({
              title: data.message,
              icon: 'none',
              duration: 1500
          })
        }
      }
      )
  }

})